<?php

namespace App\Http\Controllers\Api\V1;

use App\Admin\Repositories\AreaJobPosition;
use App\Enums\ResponseCode;
use App\Http\Controllers\Api\AbstractApiController;
use App\Http\Resources\JobpositionResource;
use App\Http\Resources\PlazaListResource;
use App\Models\BannerModel;
use App\Models\PlazaModel;
use App\Services\Banner\BannerService;
use App\Services\News\NewsService;
use App\Services\Plaza\PlazaService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class PlazaController extends AbstractApiController
{

    public function index(Request $request,PlazaService $service): JsonResponse
    {
        $user = auth('api')->user();
        $result = $service->list($user);
      
        return $this->success(trans("success"), ResponseCode::OK,new PlazaListResource($result));
    }
    /**
     * 轮播图
     * @return JsonResponse
     */
    public function bannerLists(): JsonResponse
    {
        $result = BannerService::list(BannerModel::GENRE_PLAZA);
        return $this->success(trans("success"),ResponseCode::OK,$result);
    }

    /**
     * 专区列表
     * @param Request $request
     * @param PlazaService $service
     * @return JsonResponse
     */
    public function areaList(Request $request,PlazaService $service): JsonResponse
    {
        $input = $request->validate([
            'plaza_id' => 'required|int|min:1',
        ]);
        $user = auth('api')->user();
        $result = $service->areaList($user,$input['plaza_id']);
        return $this->success(trans("success"), ResponseCode::OK,new JobpositionResource($result));
    }

}
